package com.vision.mapper;

import com.vision.pojo.entity.VideoHistory;
import com.vision.pojo.vo.VideoHistoryVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface VideoHistoryMapper {
    /**
     * 添加视频历史记录
     * @param videoId 视频ID
     * @param userId 用户ID
     */
    @Insert("insert into vs_video_history (user_id,video_id,create_time,update_time) values (#{userId},#{videoId},now(),now())")
    void insert(Integer videoId, Integer userId);

    /**
     * 删除视频历史记录
     * @param userId 用户ID
     * @param videoId 视频ID
     */
    @Delete("delete from vs_video_history where user_id = #{userId} and video_id = #{videoId}")
    void delete(Integer userId,Integer videoId);

    /**
     * 删除视频评论
     * @param videoId 视频ID
     */
    @Delete("delete from vs_video_history where video_id = #{videoId}")
    void deleteByVideoId (Integer videoId);

    /**
     * 更新视频历史记录
     * @param userId 用户ID
     * @param videoId 视频ID
     */
    @Update("update vs_video_history set update_time = now() where user_id = #{userId} and video_id = #{videoId}")
    void updateTime(Integer userId,Integer videoId);

    /**
     * 查询视频历史记录
     * @param userId 用户ID
     * @param videoId 视频ID
     * @return VideoHistory
     */
    @Select("select * from vs_video_history where user_id = #{userId} and video_id = #{videoId}")
    VideoHistory selectByUserIdAndVideoId(Integer userId,Integer videoId);

    /**
     * 查询用户的视频历史记录
     * @param userId 用户ID
     * @return List<VideoHistoryVO>
     */
    List<VideoHistoryVO> selectByUserId(Integer userId);
}
